FIND_PATH(OpenCV_INCLUDE_DIR NAMES opencv/cv.h
    HINTS
    $ENV{OPENCVDIR}
    PATH_SUFFIXES include opencv
    PATHS
    /usr
    /usr/include
    /usr/include/opencv
    /usr/local
    /usr/local/include
    /usr/local/include/opencv
    /opt
    /opt/opencv
)

SET(OpenCV_LIBRARIES)

IF(OpenCV_FIND_COMPONENTS)
    FOREACH(component ${OpenCV_FIND_COMPONENTS})
        FIND_LIBRARY(OpenCV_LIBRARY_${component} NAMES ${component}
            HINTS
            $ENV{OPENCVDIR}
            PATH_SUFFIXES lib build/lib
            PATHS
            /usr
            /usr/lib
            /usr/lib/opencv
            /usr/local
            /usr/local/lib
            /usr/local/lib/opencv
            /opt
            /opt/opencv
        )
        LIST(APPEND OpenCV_LIBRARIES ${OpenCV_LIBRARY_${component}})
    ENDFOREACH(component)
ENDIF(OpenCV_FIND_COMPONENTS)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenCV DEFAULT_MSG OpenCV_LIBRARIES OpenCV_INCLUDE_DIR)

IF(OPENCV_FOUND)
    SET(OpenCV_INCLUDE_DIRS ${OpenCV_INCLUDE_DIR})
ELSE(OPENCV_FOUND)
    SET(OpenCV_INCLUDE_DIRS)
ENDIF(OPENCV_FOUND)
